package cn.seapon.talker.fragments;

import android.R.string;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import cn.seapon.talker.R;
import cn.seapon.talker.infocarrier.SharedItems;

/** 
 * @author 作者 E-mail: 
 * @version 创建时间：2015年1月3日 下午4:43:30 
 * 类说明 
 */
public class HomeFragment extends TalkerBasedFragment{
	private static final String TAG = "我";
	private Context context;
	
	private TextView tv_nickname;
	private TextView tv_signature;
	private TextView tv_phone;
	private TextView tv_email;
	private ImageView iv_avatar;
	
	
	public HomeFragment(Context context, String content) {
		super(context, content);
		this.context = context;
	}



	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = new View(context);
		view = inflater.inflate(R.layout.fragment_home_page, container, false);
		tv_nickname = (TextView) view.findViewById(R.id.tv_nickname);
		tv_signature = (TextView) view.findViewById(R.id.tv_signature);
		tv_phone = (TextView) view.findViewById(R.id.tv_phone);
		tv_email = (TextView) view.findViewById(R.id.tv_email);
		iv_avatar = (ImageView) view.findViewById(R.id.iv_avatar);

		return view;
	}
	

	@Override
	public String getTitile() {
		return TAG;
	}



	@Override
	protected void initData() {
		
	}

	@Override
	protected void initView() {
		
	}



	@Override
	public void onResume() {
		makeText(tv_nickname, SharedItems.userInformation.getNickname());
		makeText(tv_email, SharedItems.userInformation.getEmail());
		makeText(tv_phone, SharedItems.userInformation.getPhone());
		makeText(tv_signature, SharedItems.userInformation.getSignature());
		if (SharedItems.avatarMap.containsKey(SharedItems.userInformation.getAvatar())) {
			int resId = SharedItems.avatarMap.get(SharedItems.userInformation.getAvatar());
			iv_avatar.setImageResource(resId);
		}
		super.onResume();
	}
	
	private void makeText(TextView tView,CharSequence text){
		if ("null".equals(text.toString())) {
			tView.setText("");
		}else {
			tView.setText(text);
		}
	}



	@Override
	public void onStart() {
		super.onStart();
	}

	

	@Override
	public void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}
	



}
